package com.tianqu.tms.www.user.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

import com.tianqu.tms.core.base.Logger;
import com.tianqu.tms.core.base.TmsAjaxAction;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.core.exception.TmsException;
import com.tianqu.tms.core.util.StringUtil;
import com.tianqu.tms.www.bid.action.BidStatusCheckAjaxAction;
import com.tianqu.tms.www.user.controller.UserStatusChangeResultController;
import com.tianqu.tms.www.user.viewhelper.UserDetailViewHelper;

public class UserStatusChangeAjaxAction  extends TmsAjaxAction {
	private Logger logger = Logger.getLogger(BidStatusCheckAjaxAction.class);
	
	@Override
	public void process(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response,
			UserContext uc) throws TmsException {
		logger.debug(this.getClass().getName() + "#execute was called.");
		try {
			String flag = uc.getParameter("flag");
			String login = uc.getParameter("login");
			UserDetailViewHelper userDetailViewHelper = new UserDetailViewHelper();
			if(StringUtil.isNotBlank(flag)) {
				userDetailViewHelper.setFlag(Integer.parseInt(flag));
				userDetailViewHelper.setLoginName(login);
			}
			uc.setAttribute("view",userDetailViewHelper);
			UserStatusChangeResultController controller = new UserStatusChangeResultController();
			controller.execute(uc);
			logger.debug(this.getClass().getName() + "#execute was completed.");
			responseValues(response, "1", TEXT);
		} catch (Exception e) {
			logger.error("UserStatusChangeAjaxAction error",e);
			responseValues(response, "0", TEXT);
		}
	}
}
